package com.lyncs.ods.req;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.lyncs.ods.modules.txn.model.SettlementDiscountInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * @author alex
 * @date 2022/3/11 22:17
 * @description
 */
@EqualsAndHashCode(callSuper = true)
@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class SaveSettlementReq extends SaveTxnBaseReq {

    @ApiModelProperty(value = "交付单ID")
    private Long settlementId;

    @ApiModelProperty(value = "结算日期")
    @NotNull
    private LocalDate startDate;

    @ApiModelProperty(value = "截止日期")
    @NotNull
    private LocalDate deadline;

    @ApiModelProperty(value = "结算单名称")
    private String settlementName;

    @ApiModelProperty("结算货币")
    @NotNull
    private String currency;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty("支付方式")
    private String paymentTerms;

    @ApiModelProperty("信用证编号")
    private String certNo;

    @ApiModelProperty("自定义字段信息")
    private String customFields;

    @ApiModelProperty("附件")
    private String attachment;

    @ApiModelProperty(value = "优惠信息")
    private SettlementDiscountInfo discountInfo;

    @ApiModelProperty(value = "账款信息")
    @NotNull(message = " cannot be empty")
    private List<DeliverSettleInfo> settlementBillInfos;

    @Data
    @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
    public static class DeliverSettleInfo {

        @ApiModelProperty(value = "交付单 id")
        @NotNull
        private Long deliverId;

        @ApiModelProperty(value = "结算单账款 id")
        @NotNull
        private Long billId;

        @ApiModelProperty(value = "本次结算金额")
        @NotNull
        //@Pattern(regexp = "\\d+(\\.\\d+)?", message = " illegal")
        private BigDecimal amount;

        @ApiModelProperty(value = "备注")
        private String remark;
    }
}
